package com.woniu.supermarket.service.impl;

import com.woniu.supermarket.mapper.SalesDetailMapper;
import com.woniu.supermarket.service.ISalesDetailService;
import com.woniu.supermarket.vo.SalesDetailVo;
import com.woniu.supermarket.vo.totalWithId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SalesDetailServiceImpl implements ISalesDetailService {

    @Autowired
    SalesDetailMapper salesDetailMapper;

    @Override
    public List<SalesDetailVo> quaryAll(Integer id) {
        return salesDetailMapper.selectAllVo(id);
    }

    @Override
    public void resetTotal(Integer id, Integer total) {
//        salesDetailMapper.updateTotalByPrimaryKey(id, total);
    }

    @Override
    public void resetTotalBatch(List<totalWithId> totalWithIdList) {
        salesDetailMapper.updateTotalBatch(totalWithIdList);
    }

    @Override
    public void resetTotalWithList(List<totalWithId> totalWithIdList) {
        for(totalWithId i : totalWithIdList){
            salesDetailMapper.updateTotalByPrimaryKey(i.getId(),i.getTotal());
        }
    }
}
